package com.lara;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class RegAction extends Action 
{
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception 
        {
    RegForm reg=(RegForm) form;
    //reg.setId(1);
    reg.setUsername("pankaj kumar ");
    reg.setPassword("pratima");
    System.out.println("Hello this is new change");
    System.out.println("Hello this is new change 22222");
    String s1=reg.getUsername();
    String s2=reg.getPassword();

    Configuration config=new Configuration();
    config.configure();
    hhehehe
    
    SessionFactory sf=config.buildSessionFactory();
    Session session=sf.openSession();
    session.beginTransaction();
    session.save(s1);
    session.save(s2);
    session.getTransaction().commit();
    session.flush();
    session.close();
    
    System.out.println("Hello this is new change");
    System.out.println("Hello this is new change 22222");
    
    return mapping.findForward("success");
}
}
